import 'package:flutter/material.dart';

/// Text 封装
class TextContainer extends StatelessWidget {
  final String text;
  final Color? color;
  final double? width;
  final double? height;
  final Color? bgColor;
  final int maxLines;
  final double fontSize;
  final FontWeight fontWeight;
  final TextAlign align;
  final void Function()? onClickTxt;
  final StrutStyle? strutStyle;
  final TextOverflow overflow;
  final Decoration? decoration;
  final Alignment baseAlignment;
  final EdgeInsetsGeometry? margin;
  final EdgeInsetsGeometry? padding;
  final BoxConstraints? constraints;
  final TextDirection? textDirection;
  const TextContainer({
    Key? key,
    required this.text,
    this.width,
    this.height,
    this.margin,
    this.padding,
    this.onClickTxt,
    this.strutStyle,
    this.decoration,
    this.constraints,
    this.maxLines = 1,
    this.fontSize = 16,
    this.fontWeight = FontWeight.w500,
    this.textDirection,
    this.color = Colors.white,
    this.align = TextAlign.start,
    this.bgColor = Colors.transparent,
    this.overflow = TextOverflow.ellipsis,
    this.baseAlignment = Alignment.center,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      width: width,
      height: height,
      margin: margin,
      color: bgColor,
      padding: padding,
      child: GestureDetector(
        onTap: onClickTxt,
        child: Text(
          text != null ? text.trimLeft().trimRight() : "",
          textAlign: align,
          overflow: overflow,
          maxLines: maxLines,
          strutStyle: strutStyle,
          textDirection: textDirection,
          style: TextStyle(color: color, fontSize: fontSize),
        ),
      ),
    );
  }
}
